import {
    BASE_URL
} from '../../../http/config';
Page({
    data: {
        test: [],
        img:'',
        id:''
    },
    // onLoad(options) {
    //     this.loadTestList(options.id || 1);
    //   },

    onLoad(options) {
        console.log("传过来的id");
        console.log(options);
        this.setData({
            id: options.id || this.data.id
        }, () => {
            this.loadTestList();
        });
    },

    loadTestList() {
        wx.request({
            url: `${BASE_URL}/TestClassify/findTestsByClassifyId/${this.data.id}`,
            method: "GET",
            success: (res) => {
                if (res.data && res.data.data && res.data.data.length > 0) {
                    const firstItem = res.data.data[0];
                    const listData = firstItem.psychologyTestList;
                    this.setData({
                        test: listData
                    });
                    console.log(listData);
                }
            },
            fail: (err) => {
                wx.showToast({
                    title: '加载失败',
                    icon: 'none'
                });
            },
            complete: () => {
                this.setData({
                    loading: false
                });
            }
        });
    },

    // 下拉刷新
    onPullDownRefresh() {},

    onReachBottom() {

    }
});